package com.example.auth.exception;

import com.example.mallcommon.RestResult;
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局处理Oauth2抛出的异常
 * @Author: yang
 * @Date: 2021/8/22 0022 15:07
 * @Version 0.0.1
 */
@ControllerAdvice
public class Oauth2ExceptionHandler {
    @ResponseBody
    @ExceptionHandler(value = OAuth2Exception.class)
    public RestResult handleOauth2(OAuth2Exception e) {
        return RestResult.failed(e.getMessage());
    }
}